<template>
  <h2>用户登录</h2>
  <el-form ref="formRef" :model="form" label-width="80px">
    <el-form-item label="手机号">
      <el-input v-model="form.phone" type="text"></el-input>
    </el-form-item>
    <el-form-item label="密码">
      <el-input v-model="form.password" type="password"></el-input>
    </el-form-item>
    <el-form-item>
      <el-button type="primary" @click="onSubmit">登录</el-button>
      <el-text>没有账号？
        <router-link to="/register">去注册</router-link>
      </el-text>
    </el-form-item>
  </el-form>
</template>

<script setup>
import {reactive} from 'vue';
import axios from "axios";
import router from "../router";


const form = reactive({
  phone: '',
  password: ''
})

const onSubmit = () => {
  axios.post('/api/mall-consumer/consumer/login', form)
      .then(res => {
        router.push('/')
      })
}

</script>

<style scoped>

</style>